<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Vipuserapi extends Model
{
    protected $table ='vipuser';
    public $timestamps = false;
    protected $guarded = [
        'title', 'img', 'redirect_url', 'sort', 'on_line_time', 'off_line_time', 'created_at', 'updated_at'
    ];

    public function getData(){
        $partnerList = array();
        $sql = \DB::table($this->table.' as p')
            ->select('u.nickname as name','u.avatar','u.inviteCount as invitCount','t.nickname as inviter','p.user_level')
            ->leftjoin('personInfo as u', 'u.user_id' , '=' , 'p.user_id')
            ->leftjoin('personInfo as t', 'p.inviter_id' , '=' , 't.user_id')
            ->where('u.inviteCount','>',0)
            ->where('p.ispartner',0);

        $partnerList['list'] = $sql
            ->orderBy('u.inviteCount', 'desc')

            ->get();

        return $partnerList;
    }


}